/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __QS_DepositWidget_H__
#define __QS_DepositWidget_H__

#include <QtCore/QTimer>
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QLineEdit>
#include <QtGui/QTableWidget>
#include <QtGui/QTableWidgetItem>

#include "PortfolioManager.h"
#include "QueryManager.h"
#include "DepositCreateDialog.h"

namespace QSThink
{
	
	class DepositWidget : 
		public QWidget
	{
		Q_OBJECT

	public:
		DepositWidget(QWidget *parent=0,Qt::WindowFlags flag=0);
		virtual ~DepositWidget();

		void setupDataTable();
		
	
	protected:
		void loadDeposit();
		void insertDepositRow( DepositInfo* info );
		void capitalCalc();
	protected:
		typedef std::map<QWidget*,DepositInfo*> ItemToDepositInfoMap;
		ItemToDepositInfoMap _itemToDeposits;

		QLineEdit* _lineEditSymbol;
		QComboBox* _comboSymbol;
		QTableWidget* _dataTable;
		QLabel* _labelCapital;//show all your capital
		QCompleter* _completer;
		DepositCreateDialog* _depositCreateDialog;
		

		QString _symbol;//current symbol;
		bool _symbolSelected;//start edit;

		QString _selectedText;
		bool _itemEdit;

		unsigned int _lastTime;
		float _frameRate;
		bool _inited;
	protected slots:
		void removeDeposit();
		void createDeposit();
		void tableItemChanged( QTableWidgetItem * item );
		void tableItemDoubleClicked( QTableWidgetItem * item );
		void OnDepositCreateFinished( DepositInfo * info );


	};
}
#endif
